package com.ophiux.cs.application.chat.api;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ophiux.cs.application.consult.dto.GetCSUserInfoRequest;
import com.ophiux.cs.application.consult.dto.GetCSUserInfoResponse;
import com.ophiux.cs.application.consult.service.ICSUserQueryAppService;
import com.ophiux.cs.application.core.Result;
import com.ophiux.cs.domain.chat.model.valueobj.CSUserValue;
import com.ophiux.cs.domain.chat.remote.IUserRemoteService;

/**
 * 咨询用户信息获取
 * @author chenh
 *
 */
@Service("userRemoteService")
public class UserRemoteService implements IUserRemoteService{

	@Autowired
	private ICSUserQueryAppService cSUserQueryAppService;
	
	@Override
	public CSUserValue getCSUser(String targetAcc) {
		
		GetCSUserInfoRequest request = new GetCSUserInfoRequest(targetAcc);
		
		Result<GetCSUserInfoResponse> result = cSUserQueryAppService.getCSUserInfo(request);
		
		CSUserValue csUser = null;
		
		if(result.isSuccess()) {
			GetCSUserInfoResponse resp = result.getRESPONSE();
			csUser = new CSUserValue();
			csUser.setTARGET_ACC(resp.getTARGET_ACC());
		}
		return csUser;
	}

}
